package com.hzhc.filter;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: lysys
 * @description: //文件磁盘图片url 映射
 * //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
 * @author: wxk
 * @create: 2020-02-24 14:44
 **/
@Configuration
public class FileMvcConfig implements WebMvcConfigurer {

    @Value("${file.userUploadFolder}")
    private String userUploadFolder;
    @Value("${file.userAccessPath}")
    private String userAccessPath;
    @Value("${file.yypUploadFolder}")
    private String yypUploadFolder;
    @Value("${file.yypAccessPath}")
    private String yypAccessPath;

    @Value("${file.zcUploadFolder}")
    private String zcUploadFolder;
    @Value("${file.zcAccessPath}")
    private String zcAccessPath;

    @Value("${file.cntrUploadFolder}")
    private String cntrUploadFolder;
    @Value("${file.cntrAccessPath}")
    private String cntrAccessPath;

    @Value("${file.contractFileUploadFolder}")
    private String contractFileUploadFolder;
    @Value("${file.contractFileAccessPath}")
    private String contractFileAccessPath;
    @Value("${file.appMenuImgFolder}")
    private String appMenuImgFolder;
    @Value("${file.appMenuImgAccessPath}")
    private String appMenuImgAccessPath;
    @Value("${file.padappUploadFolder}")
    private String padappUploadFolder;
    @Value("${file.padappAccessPath}")
    private String padappAccessPath;

    @Value("${file.rectifyUploadFolder}")
    private String rectifyUploadFolder;
    @Value("${file.rectifyAccessPath}")
    private String rectifyAccessPath;

    @Value("${file.ywOderFileUploadFolder}")
    private String ywOderFileUploadFolder;
    @Value("${file.ywOderFileAccessPath}")
    private String ywOderFileAccessPath;

    @Value("${file.sydImageFolader}")
    private String sydImageFolader;
    @Value("${file.sydImageAccessPath}")
    private String sydImageAccessPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //文件磁盘图片url 映射
        //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径

        registry.addResourceHandler(userAccessPath).addResourceLocations("file:" + userUploadFolder);
        registry.addResourceHandler(yypAccessPath).addResourceLocations("file:" +yypUploadFolder);
        registry.addResourceHandler(cntrAccessPath).addResourceLocations("file:" +cntrUploadFolder);
        registry.addResourceHandler(contractFileAccessPath).addResourceLocations("file:" +contractFileUploadFolder);
        registry.addResourceHandler(appMenuImgAccessPath).addResourceLocations("file:" +appMenuImgFolder);
        registry.addResourceHandler(padappAccessPath).addResourceLocations("file:"+padappUploadFolder);
        registry.addResourceHandler(rectifyAccessPath).addResourceLocations("file:"+rectifyUploadFolder);
        registry.addResourceHandler(ywOderFileAccessPath).addResourceLocations("file:" +ywOderFileUploadFolder);
        registry.addResourceHandler(sydImageAccessPath).addResourceLocations("file:" +sydImageFolader);
        registry.addResourceHandler(zcAccessPath).addResourceLocations("file:" +zcUploadFolder);
    }
}
